import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import type { IStore } from '@/interface/interface'
import $service from '@/utils/$Service'
import axios from 'axios'


export const store = defineStore('store', {
  state: (): IStore => ({
    tableData: [
      {
        date: '2016-05-03',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-02',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-04',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-01',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles,No. 189, Grove St, Los Angeles,No. 189, Grove St, Los Angeles',
      },
    ],
    count: 0,
  }),
  getters: {
    doubleCount(state) {
      return computed(() => (state.count ?? 0) * 2)
    }
  },
  actions: {
    increment() {
      this.count = (this.count ?? 0) + 1
    },
    getText() {
      let par = {
        format: 'json'
      }
      // axios.get('https://api.uomg.com/api/rand.qinghua', {
      //   params: {
      //     format: 'json'
      //   }
      // }).then((res: any) => {
      //   console.log('成功', res)
      // }).catch((err: any) => {
      //   console.log('失败', err)
      // }).finally(() => {
      // })

      $service.post('/rand.qinghua', {
        data: par
      }).then((res: any) => {
        console.log('成功', res)
      }).catch((err: any) => {
        console.log('失败', err)
      }).finally(() => {
      })


    },












  }
})
